from django.contrib import admin
import models
from djwatch.models import ServerGroupItem


class ServerGroupItemAdmin(admin.StackedInline):
    model = ServerGroupItem


class ServerGroupAdmin(admin.ModelAdmin):
    list_display = (
        'description',
    )
    inlines = [
        ServerGroupItemAdmin
    ]


class ServerAdmin(admin.ModelAdmin):
    save_on_top = True
    list_display = (
        'enabled',
        'host',
        'agent_port',
        'description',
    )
    list_display_links = (
        'host',
    )
    list_editable = (
        'enabled',
        'agent_port',
        'description',
    )
    inlines = [
    ]


class CheckAdmin(admin.ModelAdmin):
    list_display = (
        'datetime',
        'server',
        'data',
    )
    list_filter = (
        'server',
    )


class CheckErrorAdmin(admin.ModelAdmin):
    list_display = (
        'datetime',
        'server',
        'error',
    )
    list_filter = (
        'server',
    )


admin.site.register(models.ServerGroup, ServerGroupAdmin)
admin.site.register(models.Server, ServerAdmin)
admin.site.register(models.Check, CheckAdmin)
admin.site.register(models.CheckError, CheckErrorAdmin)
#admin.site.register(models.CheckWebTimeItem, CheckWebTimeItemAdmin)
